package com.zw.stock_sell_storage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zw.stock_sell_storage.dto.PurchasingDetailDto;
import com.zw.stock_sell_storage.mapper.PurchasingDetailMapper;
import com.zw.stock_sell_storage.service.IPurchasingDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PurchasingDetailServiceImpl extends ServiceImpl<PurchasingDetailMapper, PurchasingDetailDto> implements IPurchasingDetailService {
    @Autowired
    PurchasingDetailMapper purchasingDetailMapper;
    @Override
    public List<PurchasingDetailDto> queryPurchasingDetailByPurchasingId(int purchasingId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("fk_purchasing_id",purchasingId);
        return purchasingDetailMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public boolean addPurchasingDetails(List<PurchasingDetailDto> purchasingDetailList) {
        /*if (!saveBatch(purchasingDetailList)) {
            return false;
        }*/
        purchasingDetailMapper.insertPurchasingDetailList(purchasingDetailList);
        return true;
    }
}
